package com.dingup.api.enums;

import com.alibaba.fastjson.JSONObject;

/**
 * Created by wancheng on 2018/7/27.
 */
public enum ZuulHttpStatusEnum {

    LOGINSUCCESS(200,"login success"),

    LOGINFAIL(4001,"login fail"),

    CHECKTOKENFAIL(4002,"check token fail"),

    INVALID(4004,"token become invalid,you need login again"),

    TOKENNULL(4003,"token is null, this request forbiden"),

    REDISISNULL(4005,"cache is null, you need login again");

    Integer code;

    String msg;


    public static String loginSuccess(){
        return getJson(LOGINSUCCESS);
    }

    public static String tokenNull(){
        return getJson(TOKENNULL);
    }
    public static String redisIsNull(){
        return getJson(REDISISNULL);
    }
    public static String tokenInvalid(){
        return getJson(INVALID);
    }

    public static String getJson(ZuulHttpStatusEnum statusEnum){
        JSONObject json = new JSONObject();
        json.put("code",statusEnum.getCode());
        json.put("msg",statusEnum.getMsg());
        return json.toString();
    }
    public static String getJson(ZuulHttpStatusEnum statusEnum,String msg){
        JSONObject json = new JSONObject();
        json.put("code",statusEnum.getCode());
        json.put("msg",msg);
        return json.toString();
    }
    ZuulHttpStatusEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
